module-definition
Determines the module definition type (CommonJS, AMD, ES6, or none) for a given JavaScript file
by walking through the AST.
npm install module-definition
Usage
var getModuleType = require('module-definition');
getModuleType('myscript.js', function (err, type) {
console.log(type);
});
var type = getModuleType.sync('myscript.js');
console.log(type);
var type = getModuleType.fromSource('define({foo: "foo"});');
console.log(type);
Passes one of the following strings to the given callback or returns the string in sync api:
Via shell command (requires a global install: npm install -g module-definition
)
module-definition filename